<!--
@license
Copyright 2016 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<link rel="import" href="../tf-imports/polymer.html" />
<link rel="import" href="../tf-imports/d3.html" />
<link rel="import" href="../tf-imports/lodash.html" />
<link rel="import" href="../tf-imports/plottable.html" />
<link rel="import" href="../vz-chart-helpers/vz-chart-helpers.html" />

<!--
vz-bar-chart is an element for creating a Plottable ClusteredBar chart.

It makes it possible to create a bar chart (with tooltips) in 3 lines of code:

var $chart = document.createElement('vz-bar-chart');
$chart.data = {'series0': [{ x: 'a', y: 1 }, { x: 'c', y: 3 }, { x: 'b', y: 2 }],
               'series1': [{ x: 'a', y: 4 }, { x: 'g', y: 3 }, { x: 'e', y: 5 }]};
Polymer.dom(this.$container).appendChild($chart);

@element vz-bar-chart
-->
<dom-module id="vz-bar-chart">
  <template>
    <div id="tooltip">
      <table>
        <thead>
          <tr id="tooltip-table-header-row"></tr>
        </thead>
        <tbody></tbody>
      </table>
    </div>
    <div id="chartdiv"></div>
    <style include="plottable-style"></style>
    <style>
      :host {
        -webkit-user-select: none;
        -moz-user-select: none;
        display: flex;
        flex-direction: column;
        flex-grow: 1;
        flex-shrink: 1;
        position: relative;
        outline: none;
      }
      div {
        -webkit-user-select: none;
        -moz-user-select: none;
        flex-grow: 1;
        flex-shrink: 1;
      }
      td {
        padding-left: 5px;
        padding-right: 5px;
        font-size: 13px;
        opacity: 1;
      }
      #tooltip {
        pointer-events: none;
        position: absolute;
        opacity: 0;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
        font-size: 14px;
        background: rgba(0, 0, 0, 0.8);
        color: white;
        border-radius: 4px;
        line-height: 1.4em;
        padding: 8px;
        z-index: 5;
        cursor: none;
        margin-top: 10px;
      }
      .swatch {
        border-radius: 50%;
        width: 14px;
        height: 14px;
        display: block;
        border: 2px solid rgba(0, 0, 0, 0);
      }
      .closest .swatch {
        border: 2px solid white;
      }
      th {
        padding-left: 5px;
        padding-right: 5px;
        text-align: left;
      }
    </style>
  </template>
  <script src="vz-bar-chart.js"></script>
</dom-module>
